<template>
  <el-card class="box-card">
    <!-- 搜索框 -->
    <div slot="header" class="clearfix">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="姓名" class="movement">
          <el-input
            v-model="formInline.name"
            placeholder="请输入姓名"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="手机号" class="movement">
          <el-input
            v-model="formInline.phone_number"
            placeholder="请输入手机号"
            class="movement"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="工种" class="movement">
          <el-select v-model="formInline.names" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search()" class="movement"
            >查询</el-button
          >
          <el-button type="primary" @click="reset()" class="movement"
            >重置</el-button
          >
          <el-button type="primary" @click="addYuanGongs()">新增员工</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 列表展示 -->
    <div>
      <el-table
        v-loading="loading"
        :data="tableData"
        border
        style="width: 100%"
        max-height="600"
      >
        <el-table-column
          label="序号"
          align="center"
          type="index"
          :index="indexMethod"
          width="70"
        >
        </el-table-column>
        <el-table-column prop="name" align="center" label="姓名">
        </el-table-column>

        <el-table-column
          show-overflow-tooltip
          prop="img"
          align="center"
          label="头像"
        >
          <template slot-scope="scope">
            <el-image
              style="width: 50px; height: 50px"
              :src="imgHeader + scope.row.img"
              fit="cover"
            ></el-image>
          </template>
        </el-table-column>

        <el-table-column prop="user_id" align="center" label="用户编码">
        </el-table-column>
        <el-table-column prop="jiguan" align="center" label="籍贯">
        </el-table-column>
        <el-table-column prop="gonling" align="center" label="工龄">
        </el-table-column>
        <el-table-column prop="work_name" align="center" label="工种">
          <template slot-scope="scope">
            {{
              scope.row.authority_id == "4"
                ? scope.row.position_name
                : scope.row.work_name
            }}
          </template>
        </el-table-column>
        <el-table-column prop="is_baiben" align="center" label="班次">
          <template slot-scope="scope">
            {{ scope.row.is_baiben == "2" ? "夜班" : "白班" }}
          </template>
        </el-table-column>
        <!-- <el-table-column
          prop="is_status"
          align="center"
          label="状态"
          :formatter="formatUserState"
        >
        </el-table-column> -->
        <el-table-column prop="is_status" align="center" label="状态">
          <template slot-scope="scope">
            {{
              scope.row.is_status == 1
                ? "在职"
                : scope.row.is_status == 2
                ? "离职"
                : "未审核"
            }}
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="240">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.is_status === 1"
              type="danger"
              size="mini"
              @click="handleEdit(scope.row)"
              >禁用</el-button
            >
            <el-button
              v-if="scope.row.is_status == 2 || scope.row.is_status == 0"
              type="primary"
              size="mini"
              @click="handleEdit(scope.row)"
              >启用</el-button
            >
            <el-button
              v-if="scope.row.is_status === 2"
              type="danger"
              size="mini"
              @click="deleteUser(scope.row)"
              >删除</el-button
            >
            <el-button
              type="warning"
              size="mini"
              @click="compile(scope.row)"
              v-if="scope.row.is_status === 2"
              >编辑</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page"
          :page-sizes="[50, 100, 200, 300]"
          :page-size="50"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
    <!-- 新增/编辑员工 -->
    <el-dialog
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose"
      :title="titleText"
    >
      <el-form
        :model="formLabelAlign"
        label-width="85px"
        ref="form"
        :rules="rules"
      >
        <!-- <p class="addP" @click="add">新增员工</p> -->
        <div class="oneLine">
          <el-form-item label="姓名" prop="name">
            <el-input
              v-model="formLabelAlign.name"
              placeholder="请输入员工姓名"
              show-word-limit
              @input="asdasd"
            ></el-input>
          </el-form-item>
        </div>
        <div class="oneLine">
          <el-form-item label="员工编码" prop="user_id">
            <el-input
              :disabled="disabled"
              v-model="formLabelAlign.user_id"
              placeholder="请输入员工编码"
              maxlength="10"
              show-word-limit
            ></el-input>
          </el-form-item>
        </div>
        <div class="oneLine">
          <el-form-item label="手机号码" prop="phone_number">
            <el-input
              v-model="formLabelAlign.phone_number"
              placeholder="请输入员工手机号"
            ></el-input>
          </el-form-item>
        </div>
        <div class="oneLine">
          <el-form-item label="籍贯" prop="jiguan">
            <el-input
              v-model="formLabelAlign.jiguan"
              placeholder="请输入员工籍贯"
              maxlength="30"
              show-word-limit
            ></el-input>
          </el-form-item>
        </div>

        <div class="oneLine">
          <el-form-item label="工龄" prop="gonling">
            <el-input
              v-model="formLabelAlign.gonling"
              placeholder="请输入员工工龄（单位:年）"
            ></el-input>
          </el-form-item>
          <span>年</span>
        </div>
        <div class="oneLine">
          <el-form-item label="工种" prop="names">
            <el-select
              v-model="formLabelAlign.names"
              placeholder="请选择工种"
              @change="handleChange"
            >
              <el-option
                v-for="item in options"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div class="oneLine">
          <el-form-item label="班次" prop="is_baiben">
            <el-select
              v-model="formLabelAlign.is_baiben"
              placeholder="请选择班次"
            >
              <el-option
                v-for="item in options2"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div class="oneLine">
          <el-form-item label="提成方式" prop="type">
            <el-select
              v-model="formLabelAlign.type"
              placeholder="请选择提成方式"
            >
              <el-option
                v-for="item in options1"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div class="oneLine">
          <el-form-item label="提成比例" prop="proportion">
            <el-input
              v-model="formLabelAlign.proportion"
              placeholder="请输入提成比例"
            ></el-input>
          </el-form-item>
          <span>%</span>
        </div>
        <div class="oneLine">
          <el-form-item label="头像" prop="imageUrl">
            <div class="unlodBox">
              <el-upload
                class="upload-demo"
                action
                :http-request="uploadFiles"
                ref="upload"
                :limit="fileLimit"
                :on-remove="handleRemove"
                :file-list="fileList"
                :on-exceed="handleExceed"
                :before-upload="beforeUpload"
                :show-file-list="false"
                :headers="headers"
                :on-change="fileChange"
              >
                <el-image
                  v-if="imageUrl1"
                  class="imageGood"
                  :src="imgHeader + imageUrl1"
                  style="width: 360px; height: 180px"
                ></el-image>
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                <div slot="tip" class="el-upload__tip">
                  只能上传jpg/png文件，且不超过5M
                </div>
              </el-upload>
            </div>
          </el-form-item>
        </div>
      </el-form>
      <div>
        <el-button type="primary" dialogVisible class="confirm" @click="save"
          >确认</el-button
        >
      </div>
    </el-dialog>
  </el-card>
</template>

<script>
import {
  user_po_list,
  uploadFiles,
  employee,
  condition,
  userDelete,
  compileAuth,
} from "../../../../utils/api";
import {
  getStaffList,
  getGongZhongSelect,
  addYuanGong,
  delYuanGong,
  editYuanGong,
  toShenHe,
} from "../../../../utils/main";
import { compressImage } from "../../../../assets/js/compressImage";
export default {
  data() {
    return {
      options: [
        {
          value: "kanchayuan",
          label: "勘察员",
        },
      ],
      options1: [
        {
          id: "1",
          name: "材料费+工时费",
        },
        {
          id: "2",
          name: "工时费",
        },
      ],
      options2: [
        {
          id: "1",
          name: "白班",
        },
        {
          id: "2",
          name: "夜班",
        },
      ],
      imgHeader: this.Global.imgHeader,
      value: "",
      loading: false,
      token: sessionStorage.getItem("token"),
      formInline: {
        name: "",
        phone_number: "",
        names: "",
      },
      //新增员工弹框
      disabled: false,
      titleText: "",
      dialogVisible: false,
      currentPage: 1,
      total: 0,
      limit: 50,
      page: 1,
      name: "",
      authority_id: "3,4",
      phone_number: "",
      user_skill: "",
      names: "",
      type: "1",
      // authority_id: 5,
      tableData: [],
      //新增员工
      formLabelAlign: {
        name: "",
        phone_number: "",
        jiguan: "",
        gonling: "",
        names: "",
        img: "123",
        authority_id: "3,4",
        type: "1",
        proportion: "",
        is_baiben: "1",
        names: "1",
      },
      //上传图片
      imageUrl: "",
      imageUrl1: "",
      fileList: [],
      fileType: ["png", "jpg", "jpeg"],
      fileLimit: 1,
      headers: { "Content-Type": "multipart/form-data" },
      srcList2: {},
      //校验
      rules: {
        name: [
          { required: true, message: "请输入员工姓名", trigger: "blur" }, //change是数据改变，输入框一般用  blur:失去焦点触发
        ],
        user_id: [
          { required: true, message: "请输入员工编码", trigger: "blur" },
        ],
        phone_number: [
          {
            required: true,
            message: "请输入手机号码",
            trigger: "blur",
          },
          {
            validator: function (rule, value, callback) {
              if (/^1[3456789]\d{9}$/.test(value) == false) {
                callback(new Error("手机号格式错误"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
        jiguan: [
          { required: true, message: "请输入籍贯", trigger: "blur" },
          {
            validator: (rule, value, callback) => {
              var reg = /^[\u4e00-\u9fa5]+$/;
              if (!reg.test(value)) {
                callback(new Error("请输入中文"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
        gonling: [
          { required: true, message: "请输入工龄", trigger: "blur" },
          {
            validator: (rule, value, callback) => {
              var reg = /^\d+(\.\d{1,2})?$/;
              if (!reg.test(value)) {
                callback(new Error("请输入不小于0且小数位不超过两位的数字"));
              }
              if (value > 80) {
                callback(new Error("不能大于80"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
        names: [{ required: true, message: "请选择工种", trigger: "change" }],
        is_baiben: [
          { required: true, message: "请选择班次", trigger: "change" },
        ],
        type: [
          { required: true, message: "请选择提成方式", trigger: "change" },
        ],

        proportion: [
          {
            required: true,
            message: "请输入提成比例",
            trigger: "blur",
          },
          {
            validator: (rule, value, callback) => {
              var reg = /^\d+(\.\d{1,2})?$/;
              if (!reg.test(value)) {
                callback(new Error("请输入不小于0且小数位不超过两位的数字"));
              }
              if (value > 100) {
                callback(new Error("不能大于100"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
      },
      // region: [
      //   { required: true, message: "请输入员工手机号", trigger: "blur" },
      // ],
      // type: [{ required: true, message: "请输入员工职位", trigger: "blur" }],
      // phone_number: [
      //   {
      //     validatePhone: (rule, value, callback) => {
      //       const reg = /^[1][3-9][0-9]{9}$/;
      //       if (!reg.test(value) && value != "") {
      //         callback(new Error("请输入正确的电话号码"));
      //       } else {
      //         callback();
      //       }
      //     },
      //     message: "请输入正确手机号",
      //     trigger: "blur",
      //   },
      // ],
      // mobile: [
      //   { required: true, message: "请输入手机号码", trigger: "blur" },
      //   {
      //     pattern:
      //       /(^((\+86)|(86))?(1[3-9])\d{9}$)|(^(0\d{2,3})-?(\d{7,8})$)/,
      //     message: "输入的手机号码格式不正确，请重新输入",
      //     trigger: "blur",
      //   },
      // ],
    };
  },
  methods: {
    //新增员工的数据
    clearData() {
      this.formLabelAlign = {
        name: "",
        user_id: "",
        phone_number: "",
        jiguan: "",
        gonling: "",
        names: "",
        img: "",
        authority_id: "3,4",
        type: "",
        proportion: "",
        is_baiben: "",
      };
    },
    // add() {
    //   console.log(this.formLabelAlign);
    // },
    //关闭弹框
    handleClose(done) {
      this.imageUrl = "";
      this.fileList = []
      done();
      // this.$refs["form"].resetFields();
      this.$refs.form.resetFields();
      // this.clearData();
    },
    //获取工种下拉框
    async getSelect() {
      // this.loading = true;
      let res = await getGongZhongSelect(this.token, this.type)
        .then((res) => {
          // console.log(this.type, 88888);
          if (res.data.status) {
            this.options = res.data.data;
            this.options.unshift({ id: "kanchayuan", name: "勘察员" });
            // this.total = res.data.data.count;
            // console.log(111, this.options);
            // let timer = setTimeout(() => {
            //   this.loading = false;
            //   clearTimeout(timer);
            // }, 400);
          } else {
            if (res.data.msg == "token失效,请重新进行登录") {
              this.$router.push("/login");
            }
            if (res.data.msg == "此账号没有权限") {
              this.$message.error(res.data.msg);
              this.loading = false;
            }
            // let timer = setTimeout(() => {
            //   this.$message.error(res.data.msg);
            // }, 5000);
          }
        })
        .catch((err) => {
          console.log(err.message);
        });
    },
    // 查询员工
    search() {
      // this.page = 1;
      this.name = this.formInline.name;
      this.phone_number = this.formInline.phone_number;
      // if (this.formInline.names == "kanchayuan") {
      //   this.authority_id = 4;
      // } else {
      //   this.authority_id = 3;
      // }
      this.names = this.formInline.names;
      console.log(this.formInline);
      // this.authority_id = formInline.authority_id;
      // console.log(this.formInline);
      this.page = 1;
      this.getList();
    },
    // 重置
    reset() {
      this.name = "";
      this.phone_number = "";
      this.names = "";
      this.formInline.name = "";
      this.formInline.phone_number = "";
      this.formInline.names = "";
      // this.formInline = {};
      // this.options = [];
      this.authority_id = "3,4";
      this.getList();
    },
    //分页器
    //每页多少条
    handleSizeChange(val) {
      this.limit = val;
      this.getList();
    },
    //第几页
    handleCurrentChange(val) {
      this.page = val;
      this.getList();
    },
    // 获取员工列表数据
    async getList() {
      this.loading = true;
      // if (this.names === "kanchayuan") {
      //   this.authority_id = 4;
      // } else {
      //   this.authority_id = 3;
      // }
      // this.authority_id = this.formLabelAlign.authority_id;
      // this.authority_id = "3,4";
      let res = await getStaffList(
        this.token,
        this.page,
        this.limit,
        this.name,
        this.authority_id,
        this.phone_number,
        this.names
      );
      if (res.data.status) {
        this.tableData = res.data.data.data || [];
        this.total = res.data.data.count;
        // console.log(this.tableData.list, "55555");
        let timer = setTimeout(() => {
          this.loading = false;
          clearTimeout(timer);
        }, 400);
      } else {
        if (res.data.msg == "token失效,请重新进行登录") {
          this.$router.push("/login");
        }
        if (res.data.msg == "此账号没有权限") {
          this.$message.error(res.data.msg);
          this.loading = false;
        }
        let timer = setTimeout(() => {
          this.$message.error(res.data.msg);
        }, 5000);
      }
    },

    // 序号排序
    indexMethod(index) {
      if (this.total < this.limit) {
        return this.total - index;
      } else {
        return this.total - (this.page - 1) * this.limit - index;
      }
    },

    //状态值
    conditionUser(id, status) {
      condition(this.token, id, status)
        .then((res) => {
          if (res.data.status) {
            this.getList();
          } else {
            if (!res.data.status) {
              this.$message.error(res.data.msg);
            }

            if (res.data.msg == "token失效,请重新进行登录") {
              this.$router.push("/login");
            }
            if (res.data.msg == "此账号没有权限") {
              this.$message.error(res.data.msg);
              this.loading = false;
            }
            let timer = setTimeout(() => {
              this.$message.error(res.data.msg);
            }, 1000);
          }
        })
        .catch((err) => {
          console.log(err.message);
        });
    },
    //启用
    handleEdit(row) {
      if (row.is_status == 0) {
        let is_status = 1;
        this.conditionUser(row.id, is_status);
      }
      if (row.is_status == 1) {
        let is_status = 2;
        this.conditionUser(row.id, is_status);
      }
      if (row.is_status == 2) {
        let is_status = 1;
        this.conditionUser(row.id, is_status);
      }
      this.getList;
    },
    //删除
    deleteUser(row) {
      this.$confirm("此操作将永久删除该员工, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          console.log(row.id);
          delYuanGong(this.token, row.id).then((res) => {
            if (res.data.status) {
              this.$message({
                type: "success",
                message: "删除成功",
              });
              this.getList();
            } else {
              this.$message.error(res.data.msg);
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //新增员工
    handleRemove() {},
    // 新增员工
    addYuanGongs() {
      this.disabled = false;
      this.options2 = [
        {
          id: "1",
          name: "白班",
        },
        {
          id: "2",
          name: "夜班",
        },
      ];
      this.imageUrl1 = "";
      this.clearData();
      this.dialogVisible = true;
      this.titleText = "新增员工";
    },
    // 编辑员工
    compile(row) {
      let obj = JSON.parse(JSON.stringify(row));
      this.formLabelAlign = obj;
      console.log(this.formLabelAlign, "obj");
      if (row.work_name) {
        this.formLabelAlign.names = row.work_name;
        this.options2 = [
          {
            id: "1",
            name: "白班",
          },
          {
            id: "2",
            name: "夜班",
          },
        ];
      } else {
        this.formLabelAlign.names = row.position_name;
        this.options2 = [
          {
            id: "1",
            name: "白班",
          },
        ];
      }
      this.disabled = true;
      this.imageUrl1 = obj.img;
      // console.log(this.formLabelAlign);
      this.dialogVisible = true;
      this.titleText = "编辑员工";
    },
    handleChange(e) {
      // console.log(e);
      if (e === "kanchayuan") {
        this.options2 = [
          {
            id: "1",
            name: "白班",
          },
        ];
      } else {
        this.options2 = [
          {
            id: "1",
            name: "白班",
          },
          {
            id: "2",
            name: "夜班",
          },
        ];
      }
    },
    asdasd(e) {
      console.log(e.length);
    },
    save() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          // console.log(valid);
          // console.log(this.formLabelAlign, "8888880");
          // if (this.formLabelAlign.names === "水电") {
          //   this.formLabelAlign.names = 1;
          // } else if (this.formLabelAlign.names === "木") {
          //   this.formLabelAlign.names = 2;
          // } else if (this.formLabelAlign.names === "瓦") {
          //   this.formLabelAlign.names = 5;
          // } else if (this.formLabelAlign.names === "综合") {
          //   this.formLabelAlign.names = 6;
          // } else if (this.formLabelAlign.names === "勘察员") {
          //   this.formLabelAlign.names = "kanchayuan";
          // }
          this.options.forEach((item) => {
            if (item.name == this.formLabelAlign.names) {
              this.formLabelAlign.names = item.id;
            }
          });
          if (this.formLabelAlign.names === "kanchayuan") {
            this.formLabelAlign.authority_id = 4;
          } else {
            this.formLabelAlign.authority_id = 3;
          }
          if (this.formLabelAlign.id != null) {
            // 编辑
            editYuanGong(
              this.token,
              this.imageUrl1,
              this.formLabelAlign.phone_number,
              this.formLabelAlign.name,
              this.formLabelAlign.user_id,
              this.formLabelAlign.authority_id,
              this.user_skill,
              this.formLabelAlign.gonling,
              this.formLabelAlign.jiguan,
              this.formLabelAlign.names,
              this.formLabelAlign.type,
              this.formLabelAlign.proportion,
              this.formLabelAlign.id,
              this.formLabelAlign.is_baiben
            ).then((res) => {
              if (res.data.status) {
                this.$message({
                  message: res.data.msg,
                });
                this.dialogVisible = false;
                this.clearData();
                // this.formLabelAlign = {};
                this.$refs["form"].resetFields();
                this.getList();
              } else {
                this.$message.error(res.data.msg);
              }
            });
          } else {
            // console.log(this.formLabelAlign, "111");

            // 新增
            if (this.formLabelAlign.names === "kanchayuan") {
              this.formLabelAlign.authority_id = 4;
            } else {
              this.formLabelAlign.authority_id = 3;
            }
            addYuanGong(
              this.token,
              this.imageUrl1,
              this.formLabelAlign.phone_number,
              this.formLabelAlign.name,
              this.formLabelAlign.user_id,
              this.formLabelAlign.authority_id,
              this.user_skill,
              this.formLabelAlign.gonling,
              this.formLabelAlign.jiguan,
              this.formLabelAlign.names,
              this.formLabelAlign.type,
              this.formLabelAlign.proportion,
              this.formLabelAlign.is_baiben
            ).then((res) => {
              if (res.data.status) {
                this.$message({
                  message: "新增成功",
                });
                this.total = res.data.data.count;
                // this.formLabelAlign = {};
                this.dialogVisible = false;
                this.clearData();
                this.$refs["form"].resetFields();
                this.getList();
              } else {
                this.$message.error(res.data.msg);
              }
            });
          }
        } else {
          return false;
        }
      });
    },
    // submitData() {},

    //超出文件个数的回调
    handleExceed() {
      this.$message({
        type: "warning",
        message: "超出最大上传文件数量的限制！",
      });
      return;
    },
    //这是我自定义的移除事件
    handleClosedelete(i) {
      this.fileList.splice(i, 1); //删除上传的文件
    },
    //上传文件的格式
    beforeUpload(file) {
      if (file.type != "" || file.type != null || file.type != undefined) {
        //截取文件的后缀，判断文件类型
        const FileExt = file.name.replace(/.+\./, "").toLowerCase();
        //计算文件的大小
        const isLt5M = file.size / 1024 / 1024 < 1; //这里做文件大小限制
        //如果大于50M
        if (!isLt5M) {
          this.$message.error("上传文件大小不能超过 1MB!");
          return false;
        }
        //如果文件类型不在允许上传的范围内
        if (this.fileType.includes(FileExt)) {
          return true;
        } else {
          this.$message.error("上传文件格式不正确!");
          return false;
        }
      }
    },
    fileChange(file, fileList) {
      this.fileList = fileList;
    },
    // 压缩文件
    compressFile() {
      let config = {
        quality: 0.5, //默认0.5  0-1
        // width:100,
        // height:100
      };
      this.fileList.forEach(async (item) => {
        // console.log("this.fileList1", this.fileList1);
        console.log("原图size1===>", item.size);
        let result = await compressImage({
          file: item.raw,
          config,
          fileName: item.name,
        });
        console.log("压缩后图片size1===>", result.finalFile.size);
        // this.imageList.push(result);
        this.srcList2 = result.finalFile;
        // console.log("aaa", result.finalFile);
        // console.log("bbb", this.srcList2);
        // console.log("this.srcList", this.srcList);
      });
      // console.log("压缩后图片1===>", this.imageList);
    },
    //上传文件的事件
    uploadFiles(item) {
      this.$message("文件上传中........");
      //上传文件的需要formdata类型;所以要转
      this.compressFile();
      let timer = setTimeout(() => {
        uploadFiles(this.srcList2).then((res) => {
          if (res.data.status != false || res.data.id != null) {
            res.data.data.saveurl; //半截
            res.data.data.weburl; //全拼
            this.imageUrl = res.data.data.weburl;
            this.imageUrl1 = res.data.data.saveurl;
            this.fileList.push(this.srcList2); //成功过后手动将文件添加到展示列表里
            let i = this.fileList.indexOf(this.srcList2);
            this.handleSuccess();
          }
        });
        clearTimeout(timer);
      }, 1000);
      // uploadFiles(item.file).then((res) => {
      //   if (res.data.status != false || res.data.id != null) {
      //     console.log(res);
      //     res.data.data.saveurl; //半截
      //     res.data.data.weburl; //全拼
      //     this.imageUrl1 = res.data.data.saveurl;
      //     this.imageUrl = res.data.data.weburl;
      //     this.fileList.push(item.file); //成功过后手动将文件添加到展示列表里
      //     let i = this.fileList.indexOf(item.file);
      //     this.handleSuccess(i);
      //   }
      // });
    },
    //上传成功后的回调
    handleSuccess(i) {
      this.$message({
        message: "上传成功",
        type: "success",
      });
      this.handleClosedelete(i);
    },
    formatUserState(row) {
      let is_status = row.is_status;
      if (is_status === 1) {
        return "在职";
      } else if (is_status === 2) {
        return "离职";
      } else {
        return "未审核";
      }
    },
  },
  mounted() {
    // this.toAdd();
    this.getSelect();
    // this.search();
    this.getList();
    // this.addList();
  },
};
</script>

<style scoped>
.confirm {
  margin-left: 40%;
}

.movement {
  margin-right: 10px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.oneLine {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 10px;
  /* border: 1px solid pink; */
}
span {
  position: relative;
  top: -10px;
  left: 5px;
}
/* .el-form-item {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  border: 1px solid black;
} */
.addP {
  font-size: 22px;
  text-align: center;
  margin-bottom: 10px;
}
</style>